package com.brisk.web.controller.applet;

import com.ruoyi.applet.domain.AppletExamUser;
import com.ruoyi.applet.service.IAppletExamUserService;
import com.brisk.common.annotation.Log;
import com.brisk.common.core.controller.BaseController;
import com.brisk.common.core.domain.AjaxResult;
import com.brisk.common.core.page.TableDataInfo;
import com.brisk.common.enums.BusinessType;
import com.brisk.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * examUserController
 *
 * @author PengFei Deng
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/applet/examUser")
public class AppletExamUserController extends BaseController {
    @Autowired
    private IAppletExamUserService appletExamUserService;

    /**
     * 查询examUser列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppletExamUser appletExamUser) {
        startPage();
        List<AppletExamUser> list = appletExamUserService.selectAppletExamUserList(appletExamUser);
        return getDataTable(list);
    }

    /**
     * 导出examUser列表
     */
    @Log(title = "examUser", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletExamUser appletExamUser) {
        List<AppletExamUser> list = appletExamUserService.selectAppletExamUserList(appletExamUser);
        ExcelUtil<AppletExamUser> util = new ExcelUtil<AppletExamUser>(AppletExamUser.class);
        util.exportExcel(response, list, "examUser数据");
    }

    /**
     * 获取examUser详细信息
     */
    @GetMapping(value = "/{joinId}")
    public AjaxResult getInfo(@PathVariable("joinId") Long joinId) {
        return AjaxResult.success(appletExamUserService.selectAppletExamUserByJoinId(joinId));
    }

    /**
     * 新增examUser
     */
    @Log(title = "examUser", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletExamUser appletExamUser) {
        return toAjax(appletExamUserService.insertAppletExamUser(appletExamUser));
    }

    /**
     * 修改examUser
     */
    @Log(title = "examUser", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletExamUser appletExamUser) {
        return toAjax(appletExamUserService.updateAppletExamUser(appletExamUser));
    }

    /**
     * 删除examUser
     */
    @Log(title = "examUser", businessType = BusinessType.DELETE)
    @DeleteMapping("/{joinIds}")
    public AjaxResult remove(@PathVariable Long[] joinIds) {
        return toAjax(appletExamUserService.deleteAppletExamUserByJoinIds(joinIds));
    }
}
